﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using WarehouseManagement.BusinessLogic.BC;
using WarehouseManagement.ViewModels.PO;

namespace WarehouseManagement.Presenters.PO
{
    public class ViewPOPresenter : BasePresenter<IViewPOViewModel>
    {
        protected override void WireupEventHandles()
        {

        }

        POBC _ieBC;

        public ViewPOPresenter()
        {
            _ieBC = new POBC();
        }


        private void LoadImportList(DateTime from, DateTime to)
        {
            var list = _ieBC.GetViewPOList(from.Date, to.Date);
            Model.POList = list.OrderBy(e => e.PONumber).ToList();
        }

        public void LoadImportList()
        {
            if (Model.FromDate == DateTime.MinValue)
            {
                Model.POList = null;
                return;
            }

            DateTime toDate = Model.ToDate;
            if (Model.ToDate == DateTime.MinValue)
                toDate = DateTime.Now;
            LoadImportList(Model.FromDate.Date, toDate.Date);
        }
    }
}
